package programmercarl.动态规划.C41;

class Solution1 {
    public static int lengthOfLIS(int[] nums) {
        int[] dp = new int[nums.length];//以i为结尾的最长上升子序列
        for (int i = 0; i < nums.length; i++) {
            dp[i]=1;
        }
        int res = 1;
        for (int i = 1; i < nums.length; i++) {
            for (int j = 0; j < i; j++) {
                if (nums[i] > nums[j]) {
                    dp[i] = Math.max(dp[i], dp[j] + 1);
                    res = Math.max(res, dp[i]);
                }
            }
        }
        return res ;
    }

    public static void main(String[] args) {
        int length = lengthOfLIS(new int[]{10, 9, 2, 5, 3, 7, 101, 18});
        System.out.println(length);
    }


}